package com.kitty.game.gm.handler;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.chat.service.ChatService;
import com.kitty.game.notice.model.Notice;
import com.kitty.game.role.model.Account;
import com.kitty.game.role.model.Role;
import com.kitty.game.role.service.AccountService;
import com.kitty.game.utils.PrivilegeConst;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;

public class GmGonggao implements GMFather {

    @Override
    public boolean handle(Role aaaaa, String content) {
        Account account = SpringUtils.getBean(AccountService.class).getAccount(aaaaa.getSid());
        if (account.getPrivilege() < PrivilegeConst.GM) {
            return true;
        }
        SpringUtils.getBean(ChatService.class).sendAdnotice(content);
        Dao dao = SpringUtils.getBean(Dao.class);
        Notice notice = dao.fetch(Notice.class, Cnd.NEW());
        if (notice == null){
            notice = new Notice();
        }
        notice.setContent(content);
        dao.insertOrUpdate(notice);
        return true;
    }
}
